'use strict';

/**
 * @ngdoc function
 * @name jgappApp.controller:TaskWeeklylistCtrl
 * @description
 * # TaskWeeklylistCtrl
 * Controller of the jgappApp
 */
angular.module('jgappApp')
    .controller('TaskWeeklylistCtrl', function(DataService, DataByPage, openApi, $location, $routeParams) {
        var param = {};
        if ($routeParams.type == "date") {
            param.year = $routeParams.data.split("&&")[0]
            param.weekOfYear = $routeParams.data.split("&&")[1]
        } else if ($routeParams.type == "people") {
            param.userId = $routeParams.data
        } else if ($routeParams.type == "dep") {
            param.departmentId = $routeParams.data
        }
        this.initData = function() {
            this.weeklylist = new DataByPage(openApi.getweeklyByconditionApp, param);
        }
        this.initData();
        this.goDetail = function(item) {
            this.hasSeenWeekly(item.pkId)
            console.log(item)
            var param = {}
            param.pkId = item.pkId;
            $location.path("task/weeklydetail/" + item.pkId)
        }
        this.hasSeenWeekly = function(pkId) {
            var param = {}
            param.refId = pkId;
            DataService.getData(openApi.hasSeenByworkweekly, param).then(function(data) {}.bind(this))
        }
    });
